from PySide6.QtWidgets import (QLabel,QLineEdit,QPushButton,QCheckBox,QComboBox,QMessageBox,QPlainTextEdit,QHBoxLayout)
from PySide6.QtGui import (QPixmap)
from PySide6.QtCore import (QRect,QSize)
from conf.DiaLogResult import *
from conf.Edit.MyCanvasWidget import *

class Ui_Form(object):
    def __init__(self,Form,w,h) -> None:
        self.Form = Form
        self.MapBG =  QLabel(self.Form)
        self.MapBG.setGeometry(0,0,420,420)
        self.MapBG.setPixmap(QPixmap(f'lib/images/terrains.png').copy(QRect(0,0,32,32)).scaled(QSize(420,420)))
        self.MapBG.setStyleSheet("")
        self.msgLev = ["消息","警告","错误"]
        self.Form.resize(w,h)

    # 开窗
    def ShowDiaLog_Window(self,msg,level=0,BtnOK="确认",BtnCancel="取消",form=None):
        """弹窗提示"""
        if form is None:
            form = self.Form
        msgWin = QMessageBox(form)
        msgWin.setText(str(msg))
        msgWin.setWindowTitle(self.msgLev[level])
        msgWin.setStandardButtons(msgWin.StandardButton.Ok | msgWin.StandardButton.Cancel)
        msgWin.setButtonText(msgWin.StandardButton.Ok,BtnOK)
        msgWin.setButtonText(msgWin.StandardButton.Cancel,BtnCancel)
        ret = msgWin.exec()
        if ret == msgWin.StandardButton.Ok:
            return DiaLogResult.OK
        elif ret == msgWin.StandardButton.Cancel:
            return DiaLogResult.Cancel
        
    # 创建标签
    def createLab(self,boxName=None,x=0,y=0,w=100,h=20,form=None,MW=None,MH=None,style=None) ->QLabel:
        """创建标签,如果boxName为None,那么宽度为自定义,否则宽度根据文本内容自动适应
        \n Eval封装"""
        if form is None:
            form = self.Form
        control = QLabel(form)

        if boxName is None:
            control.setGeometry(int(x),int(y),int(w),int(h))
        else:
            control.setGeometry(x,y,len(boxName*13),h)
            control.setObjectName(boxName)
            control.setText(boxName)
        control.setStyleSheet(style if not style is None else "font-size:12px;background-color: rgb(255, 255, 255);")
        self._resetMaxMinRect(control,MW,MH)
        return control

    # 创建输入框
    def createLineBox(self,x=0,y=0,w=100,h=20,boxName="输入框",form=None,value="",MW=None,MH=None,labName=None) ->QLineEdit:
        """创建输入框 
        \n Eval封装"""
        if form is None:
            form = self.Form
        control = QLineEdit(form)
        if labName is not None:
            checkLab = self.createLab(labName,x,y,form=form)
            control.setGeometry(checkLab.width()+3+int(x),int(y),int(w),int(h))
        else:
            control.setGeometry(int(x),int(y),int(w),int(h))
        control.setObjectName(boxName)
        control.setText(str(value))
        control.setStyleSheet("background-color: rgb(255, 255, 255);")
        self._resetMaxMinRect(control,MW,MH)
        return control
    
    
    # 创建多行输入框
    def createPlainTextBox(self,x=0,y=0,w=500,h=50,boxName="输入框",form=None,value="",MW=None,MH=None,labName=None) ->QPlainTextEdit:
        """创建输入框 
        \n Eval封装"""
        if form is None:
            form = self.Form
        control = QPlainTextEdit(form)
        if labName is not None:
            checkLab = self.createLab(labName,x,y,form=form)
            control.setGeometry(checkLab.width()+3+int(x),int(y),int(w),int(h))
        else:
            control.setGeometry(int(x),int(y),int(w),int(h))
        control.setObjectName(boxName)
        control.setPlainText(str(value))
        control.setStyleSheet("background-color: rgb(255, 255, 255);")
        self._resetMaxMinRect(control,MW,MH)
        return control


    # 创建按钮
    def createBtnBox(self,boxName,x=0,y=0,w=60,h=20,fontSize=12,event=None,form=None,eventArgs=None,MW=None,MH=None) ->QPushButton:
        """创建按钮 
        \n Eval封装"""
        if form is None:
            form = self.Form
        control = QPushButton(form)
        control.setObjectName(str(boxName))
        control.setText(str(boxName))
        # 如果字符不超过 4个的,或者宽度是默认值的  保持默认宽度
        if len(boxName) <= 4 and w == 60:
            boxName = ""
        control.setGeometry(int(x),int(y),int(w)+len(boxName)*fontSize,int(h))
        control.setStyleSheet(f"selection-color: rgb(255, 255, 127);background-color: rgb(255, 255, 255);font-size:{fontSize}px")
        if not event is None:
            if not eventArgs is None:
                control.clicked.connect(lambda:event(eventArgs))
            else:
                control.clicked.connect(lambda:event())
        self._resetMaxMinRect(control,MW,MH)
        return control

    # 创建单选框
    def createCheckBox(self,x=0,y=0,w=15,h=15,isChecked = True,MW=None,MH=None,form=None,boxName="单选组件",labName=None) ->QCheckBox:
        """创建单选框 
        \n Eval封装"""
        if form is None:
            form = self.Form
        control = QCheckBox(form)
        if labName is not None:
            checkLab = self.createLab(labName,x,y-3,form=form)
            control.setGeometry(checkLab.width()+3+int(x),int(y),int(w),int(h))
        else:
            control.setGeometry(int(x),int(y),int(w),int(h))
            
        if type(isChecked) == str:
            isChecked = True if isChecked == "true" else False
        control.setChecked(isChecked)
        control.setObjectName(boxName)
        self._resetMaxMinRect(control,MW,MH)
        return control

    # 创建下拉选项组件 
    def createComboBox(self,x=0,y=0,w=100,h=20,array:list =[],form=None,boxName="下拉选项组件",labName=None) ->QComboBox:
        f"""创建下拉选项组件 
        \n Eval封装"""
        if form is None:
            form = self.Form
        control = QComboBox(form)
        if labName is not None:
            checkLab = self.createLab(labName,x,y,form=form)
            control.setGeometry(checkLab.width()+3+int(x),int(y),int(w),int(h))
        else:
            control.setGeometry(int(x),int(y),int(w),int(h))
        control.setObjectName(boxName)
        control.addItems(array)
        return control
    
    def _resetMaxMinRect(self,con:QLabel,MW,MH):
        """仅供内部调用的设置组件最大最小值方法"""
        if not MW is None:
            con.setMinimumWidth(MW)
            con.setMaximumWidth(MW)
        if not MH is None:
            con.setMinimumHeight(MW)
            con.setMaximumHeight(MW)
    
    def Canvas_speakTip(self,form,e:dict):
        """绘制对话组件"""
        msg=e["msg"]
        title=e["data"][0]
        icon=e["data"][1]
        win = MyCanvasWidget(form,style=f"background-color:rgba(91,165,159,1);border-radius:5px;",w=550,h=70,conName=e["type"])
        # 消息输入框
        msgLab = self.createLab("消息",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        line_msg = self.createPlainTextBox(form=win,value=msg,boxName="消息")
        # 消息标题输入框
        msgTitle = self.createLab("标题",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        msgT_line = self.createLineBox(form=win,value=title,boxName="标题")
        # 消息标题输入框
        msgIcon = self.createLab("图像",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        msgT_Icon = self.createLineBox(form=win,value=icon,boxName="图像")

        layout = QHBoxLayout(form)
        conArr = [msgLab,line_msg,msgTitle,msgT_line,msgIcon,msgT_Icon]
        for con in conArr:
            layout.addWidget(con)
        # 将所有的小组件都布局到win 主窗体中
        win.setLayout(layout)
        return win
    
    def Canvas_SetBlock(self,form,e):
        """转换图块组件"""
        blockName=e["blockName"]
        loc=e["loc"]
        floorName= e["floorId"]
        win = MyCanvasWidget(form,style=f"background-color:rgba(84,139,84,1);border-radius:5px;",w=360,h=35,conName=e["type"])
        
        msgLab = self.createLab("转变图块为",form=win,MW=90,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        # 图块名称输入框
        line_blockName = self.createLineBox(form=win,value=blockName,MW=70,boxName="图块")
        # x坐标
        lab_x = self.createLab("x",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;margin-left:15px;")
        line_blockX = self.createLineBox(form=win,value=loc[0],MW=30,boxName="x")
        # y坐标
        lab_y = self.createLab(", y",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        line_blocY = self.createLineBox(form=win,value=loc[1],MW=30,boxName="y")
        # 楼层
        lab_floor = self.createLab("楼层",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        line_floor = self.createLineBox(form=win,value=floorName,MW=50,boxName="楼层")
        
        # 将所有的小组件都布局到win 主窗体中
        layout = QHBoxLayout(form)

        conArr = [msgLab,line_blockName,lab_x,line_blockX,lab_y,line_blocY,lab_floor,line_floor]
        for con in conArr:
            layout.addWidget(con)
        # 将所有的小组件都布局到win 主窗体中
        win.setLayout(layout)
        
        return win
    
    def Canvas_openDoor(self,form,e):
        """开门组件"""
        loc=e["loc"]
        floorName= e["floorId"]
        needKey=e["needKey"]
        win = MyCanvasWidget(form,style=f"background-color:rgba(30,144,255,1);border-radius:5px;",w=340,h=35,conName=e["type"])
        
        msgLab = self.createLab("开门",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        # x坐标
        lab_x = self.createLab("x",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        line_blockX = self.createLineBox(form=win,value=loc[0],MW=30,boxName="x")
        # y坐标
        lab_y = self.createLab(", y",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        line_blocY = self.createLineBox(form=win,value=loc[1],MW=30,boxName="y")
        # 楼层
        lab_floor = self.createLab("楼层",form=win)
        lab_floor.setStyleSheet("background-color:rgba(91, 165, 159,.0);color:rgb(255,255,255);font-weight:700;")
        line_floor = self.createLineBox(form=win,value=floorName,MW=70,boxName="楼层")

        # 是否需要钥匙
        lab_key = self.createLab("需要钥匙",form=win,MW=60,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        check_key = self.createCheckBox(isChecked=needKey,MW=15,boxName="key")
        
        # 将所有的小组件都布局到win 主窗体中
        layout = QHBoxLayout(form)
        arr = [msgLab,lab_x,line_blockX,lab_y,line_blocY,lab_floor,line_floor,lab_key,check_key]
        for i in arr:
            layout.addWidget(i)
        # 将所有的小组件都布局到win 主窗体中
        win.setLayout(layout)
        
        return win
    
    def Canvas_closeDoor(self,form,e):
        """关门组件"""
        loc=e["loc"]
        win = MyCanvasWidget(form,style=f"background-color:rgba(30,144,255,1);border-radius:5px;",w=150,h=35,conName=e["type"])
        
        msgLab = self.createLab("关门",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        # x坐标
        lab_x = self.createLab("x",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        line_blockX = self.createLineBox(form=win,value=loc[0],MW=30,boxName="x")
        # y坐标
        lab_y = self.createLab(", y",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        line_blocY = self.createLineBox(form=win,value=loc[1],MW=30,boxName="y")
        
        # 将所有的小组件都布局到win 主窗体中
        layout = QHBoxLayout(form)
        arr = [msgLab,lab_x,line_blockX,lab_y,line_blocY]
        for i in arr:
            layout.addWidget(i)
        # 将所有的小组件都布局到win 主窗体中
        win.setLayout(layout)
        
        return win
    
    def Canvas_playSound(self,form,e):
        """音效组件"""
        win = MyCanvasWidget(form,style=f"background-color:rgba(124,152,50,1);border-radius:5px;",w=240,h=35,conName=e["type"])
        
        # 音效名称
        lab_x = self.createLab("播放音效",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        line_blockX = self.createLineBox(form=win,value=e["name"],MW=150,boxName="music")
        
        # 将所有的小组件都布局到win 主窗体中
        layout = QHBoxLayout(form)
        arr = [lab_x,line_blockX]
        for i in arr:
            layout.addWidget(i)
        # 将所有的小组件都布局到win 主窗体中
        win.setLayout(layout)
        
        return win
    
    def Canvas_hide(self,form,e):
        """隐藏事件 组件"""
        loc=e["loc"]
        floorId=e["floorId"]
        remove=e["remove"]
        win = MyCanvasWidget(form,style=f"background-color:rgba(205,133,63,1);border-radius:5px;",w=360,h=35,conName=e["type"])
        msgLab = self.createLab("隐藏事件",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        # x坐标
        lab_x = self.createLab("x",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        line_blockX = self.createLineBox(form=win,value=loc[0],MW=30,boxName="x")
        # y坐标
        lab_y = self.createLab(", y",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        line_blocY = self.createLineBox(form=win,value=loc[1],MW=30,boxName="y")
        # 楼层
        lab_floor = self.createLab("楼层",form=win)
        lab_floor.setStyleSheet("background-color:rgba(91, 165, 159,.0);color:rgb(255,255,255);font-weight:700;")
        line_floor = self.createLineBox(form=win,value=floorId,MW=70,boxName="楼层")

        # 是否同时删除该点事件
        lab_key = self.createLab("删除事件",form=win,MW=60,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;margin-left:10px;")
        check_key = self.createCheckBox(isChecked=remove,MW=15,boxName="删除事件")
        
        # 将所有的小组件都布局到win 主窗体中
        layout = QHBoxLayout(form)
        arr = [msgLab,lab_x,line_blockX,lab_y,line_blocY,lab_floor,line_floor,lab_key,check_key]
        for i in arr:
            layout.addWidget(i)
        # 将所有的小组件都布局到win 主窗体中
        win.setLayout(layout)
        
        return win
    
    def Canvas_tip(self,form,e):
        """消息提示 组件"""
        value=e["text"]
        icon=e["icon"]
        win = MyCanvasWidget(form,style=f"background-color:rgba(144,238,144,1);border-radius:5px;",w=360,h=35,conName=e["type"])
        msgLab = self.createLab("显示提示：",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;",MW=50)
        # 显示提示：
        line_msg = self.createLineBox(form=win,value=value,MW=200,boxName="msg")
        # 图标ID
        lab_y = self.createLab("图标ID",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;margin-left:10px;")
        line_blocY = self.createLineBox(form=win,value=icon,MW=30,boxName="img")
        # 将所有的小组件都布局到win 主窗体中
        layout = QHBoxLayout(form)
        arr = [msgLab,line_msg,lab_y,line_blocY]
        for i in arr:
            layout.addWidget(i)
        # 将所有的小组件都布局到win 主窗体中
        win.setLayout(layout)
        return win
    
    def Canvas_input(self,form,e):
        """接收输入 组件"""
        win = MyCanvasWidget(form,style=f"background-color:rgba(72,118,255,1);border-radius:5px;",w=350,h=35,conName=e["type"])
        msgLab = self.createLab("接收用户输入文本:",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;",MW=100)
        # 显示提示：
        line_msg = self.createLineBox(form=win,value=e["text"],MW=220,boxName="msg")
        # 将所有的小组件都布局到win 主窗体中
        layout = QHBoxLayout(form)
        arr = [msgLab,line_msg]
        for i in arr:
            layout.addWidget(i)
        # 将所有的小组件都布局到win 主窗体中
        win.setLayout(layout)
        return win
    
    def Canvas_useItem(self,form,e):
        """使用道具 组件"""
        win = MyCanvasWidget(form,style=f"background-color:rgba(147,112,219,1);border-radius:5px;",w=200,h=35,conName=e["type"])
        msgLab = self.createLab("使用道具:",form=form,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;",MW=50)
        # 显示提示：
        line_msg = self.createLineBox(form=win,value=e["id"],MW=120,boxName="id")
        # 将所有的小组件都布局到win 主窗体中
        layout = QHBoxLayout(form)
        arr = [msgLab,line_msg]
        for i in arr:
            layout.addWidget(i)
        # 将所有的小组件都布局到win 主窗体中
        win.setLayout(layout)
        return win
    
    def Canvas_addItem(self,form,e):
        """获得道具 组件"""
        win = MyCanvasWidget(form,style=f"background-color:rgba(147,112,219,1);border-radius:5px;",w=250,h=35,conName=e["type"])
        # 显示提示：
        line_msg = self.createLineBox(form=win,value=e["id"],MW=120,boxName="id")
        msgLab = self.createLab("获得道具:",form=form,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;",MW=50)
        
        lab_y = self.createLab("值",form=form,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;margin-left:10px;")
        line_blocY = self.createLineBox(form=win,value=e["value"],MW=30,boxName="value")
        # 将所有的小组件都布局到win 主窗体中
        layout = QHBoxLayout(form)
        arr = [msgLab,line_msg,lab_y,line_blocY]
        for i in arr:
            layout.addWidget(i)
        # 将所有的小组件都布局到win 主窗体中
        win.setLayout(layout)
        return win
    
    def Canvas_exit(self,form):
        """退出 组件"""
        win = MyCanvasWidget(form,style=f"background-color:rgba(30,144,255,1);border-radius:5px;",w=110,h=35)
        msgLab = self.createLab("立刻结束当前事件",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;",MW=100)
        # 将所有的小组件都布局到win 主窗体中
        layout = QHBoxLayout(form)
        layout.addWidget(msgLab)
        # 将所有的小组件都布局到win 主窗体中
        win.setLayout(layout)
        return win
      
    def Canvas_if(self,form,value):
        """if else 判断 组件"""
        win = MyCanvasWidget(form,style=f"background-color:rgba(178,34,34,1);border-radius:5px;",w=540,h=35)
        # lav_if = self.createLab(f"如果:",form=form,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;",MW=540)
        # offset = 0
        # layout = QVBoxLayout(form)
        # for e in value["true"]:
        #     control:QLabel =None
        #     match(e["type"]):
        #         case "speakTip":
        #             # 对话事件
        #             control = self.Canvas_speakTip(lav_if,msg=e["msg"],title=e["data"][0],icon=e["data"][1])
                    
        #         case "setBlock":  # 转换图库
        #             control = self.Canvas_SetBlock(lav_if,blockName=e["blockName"],loc=e["loc"],floorName= e["floorId"])
        #             control.setStyleSheet("margin-left:50px;")

        #         case "openDoor":  # 开门
        #             control = self.Canvas_openDoor(lav_if,loc=e["loc"],floorName= e["floorId"],needKey=e["needKey"])
                    
        #         case "closeDoor":  # 关门
        #             control = self.Canvas_closeDoor(lav_if,loc=e["loc"])

        #         case "playSound":  # 播放音效
        #             control = self.Canvas_playSound(lav_if,e["name"])

        #         case "hide":  # 隐藏事件
        #             control = self.Canvas_hide(lav_if,loc=e["loc"],floorId=e["floorId"],remove=e["remove"])

        #         case "tip":  # 消息提示
        #             control = self.Canvas_tip(lav_if,value=e["text"],icon=e["icon"])
        #         case "input":  # 接受输入
        #             control = self.Canvas_input(lav_if,value=e["text"])

        #         case "useItem":  # 使用道具
        #             control = self.Canvas_useItem(lav_if,id=e["id"])

        #         case "exit":  # 立刻结束当前事件
        #             control = self.Canvas_exit(lav_if)

        #         case "if":  # if else 事件   比较复杂,以后在啃
        #             control = self.Canvas_if(lav_if,e)


        #         case _: # 缺省值
        #             control = self.Canvas_None(lav_if,conName=e["type"])

        #     control.setStyleSheet("margin-left:20px;")
        #     offset+=control.height()
        #     layout.addWidget(control)

        # lav_if.setLayout(layout)
        # # 条件
        # line_value = self.createLineBox(form=win,value=value["condition"],MW=50)
        # lav_else = self.createLab(f"否则:",form=form,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;",MW=50)

        # # 将所有的小组件都布局到win 主窗体中
        # layout = QHBoxLayout(form)
        # qv = QVBoxLayout(form)
        # arr = [lav_if,line_value,lav_else]
        # for i in arr:
        #     offset += i.height() +20
        #     qv.addWidget(i)
        # # layout.addWidget(qv)
        # win.setMinimumHeight(offset)
        # win.setMaximumHeight(offset)
        # # 将所有的小组件都布局到win 主窗体中
        # win.setLayout(qv)
        return win
    
    def Canvas_comment(self,form,e):
        """注释 组件"""
        win = MyCanvasWidget(form,style=f"background-color:rgba(147, 91, 165,1);border-radius:5px;",w=400,h=35,conName=e["type"])
        msgLab = self.createLab("添加注释",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;",MW=50)
        # 显示提示：
        line_msg = self.createLineBox(form=win,value=e["text"],MW=300,boxName="msg")
        # 将所有的小组件都布局到win 主窗体中
        layout = QHBoxLayout(form)
        arr = [msgLab,line_msg]
        for i in arr:
            layout.addWidget(i)
        # 将所有的小组件都布局到win 主窗体中
        win.setLayout(layout)
        return win

    def Canvas_None(self,form,conName):
        """未知 组件"""
        win = MyCanvasWidget(form,style=f"background-color:rgba(178,34,34,.7);border-radius:5px;",w=150,h=35)
        msgLab = self.createLab(f"未知组件:{conName}",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;",MW=140)
        # 将所有的小组件都布局到win 主窗体中
        layout = QHBoxLayout(form)
        layout.addWidget(msgLab)
        # 将所有的小组件都布局到win 主窗体中
        win.setLayout(layout)
        return win

    def Canvas_changeFloor(self,form,e):
        """切换楼层组件"""
        loc=e["loc"]
        floorName= e["floorId"]
        win = MyCanvasWidget(form,style=f"background-color:rgb(91, 165, 103);border-radius:5px;",w=255,h=35,conName=e["type"])
        
        lab_floor = self.createLab("楼层切换",form=win)
        lab_floor.setStyleSheet("background-color:rgba(91, 165, 159,.0);color:rgb(255,255,255);font-weight:700;")
        line_floor = self.createLineBox(form=win,value=floorName,MW=70,boxName="楼层")
        # x坐标
        lab_x = self.createLab("x",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;margin-left:20px")
        line_blockX = self.createLineBox(form=win,value=loc[0],MW=30,boxName="x")
        # y坐标
        lab_y = self.createLab(",y",form=win,style="background-color:rgba(0, 0, 0,0);color:rgb(255,255,255);font-weight:700;")
        line_blocY = self.createLineBox(form=win,value=loc[1],MW=30,boxName="y")
        
        # 将所有的小组件都布局到win 主窗体中
        layout = QHBoxLayout(form)
        arr = [lab_floor,line_floor,lab_x,line_blockX,lab_y,line_blocY]
        for i in arr:
            layout.addWidget(i)
        # 将所有的小组件都布局到win 主窗体中
        win.setLayout(layout)
        
        return win
    
    # 统一点击事件
    def AllClick(self,form,parent):
        form.cureChild = parent
        form.currCheck.setEnabled(True)  # 不能手动修改,